home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / SpeechSynthesis.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  13.1 KB  |  389 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        SpeechSynthesis.h
  3.  
  4.      Contains:    Speech Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1989-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __SPEECHSYNTHESIS__
  19. #define __SPEECHSYNTHESIS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53.  
  54. enum {
  55.     kTextToSpeechSynthType        = FOUR_CHAR_CODE('ttsc'),
  56.     kTextToSpeechVoiceType        = FOUR_CHAR_CODE('ttvd'),
  57.     kTextToSpeechVoiceFileType    = FOUR_CHAR_CODE('ttvf'),
  58.     kTextToSpeechVoiceBundleType = FOUR_CHAR_CODE('ttvb')
  59. };
  60.  
  61.  
  62. enum {
  63.     kNoEndingProsody            = 1,
  64.     kNoSpeechInterrupt            = 2,
  65.     kPreflightThenPause            = 4
  66. };
  67.  
  68.  
  69. enum {
  70.     kImmediate                    = 0,
  71.     kEndOfWord                    = 1,
  72.     kEndOfSentence                = 2
  73. };
  74.  
  75.  
  76. /*------------------------------------------*/
  77. /* GetSpeechInfo & SetSpeechInfo selectors    */
  78. /*------------------------------------------*/
  79.  
  80. enum {
  81.     soStatus                    = FOUR_CHAR_CODE('stat'),
  82.     soErrors                    = FOUR_CHAR_CODE('erro'),
  83.     soInputMode                    = FOUR_CHAR_CODE('inpt'),
  84.     soCharacterMode                = FOUR_CHAR_CODE('char'),
  85.     soNumberMode                = FOUR_CHAR_CODE('nmbr'),
  86.     soRate                        = FOUR_CHAR_CODE('rate'),
  87.     soPitchBase                    = FOUR_CHAR_CODE('pbas'),
  88.     soPitchMod                    = FOUR_CHAR_CODE('pmod'),
  89.     soVolume                    = FOUR_CHAR_CODE('volm'),
  90.     soSynthType                    = FOUR_CHAR_CODE('vers'),
  91.     soRecentSync                = FOUR_CHAR_CODE('sync'),
  92.     soPhonemeSymbols            = FOUR_CHAR_CODE('phsy'),
  93.     soCurrentVoice                = FOUR_CHAR_CODE('cvox'),
  94.     soCommandDelimiter            = FOUR_CHAR_CODE('dlim'),
  95.     soReset                        = FOUR_CHAR_CODE('rset'),
  96.     soCurrentA5                    = FOUR_CHAR_CODE('myA5'),
  97.     soRefCon                    = FOUR_CHAR_CODE('refc'),
  98.     soTextDoneCallBack            = FOUR_CHAR_CODE('tdcb'),        /* use with SpeechTextDoneProcPtr*/
  99.     soSpeechDoneCallBack        = FOUR_CHAR_CODE('sdcb'),        /* use with SpeechDoneProcPtr*/
  100.     soSyncCallBack                = FOUR_CHAR_CODE('sycb'),        /* use with SpeechSyncProcPtr*/
  101.     soErrorCallBack                = FOUR_CHAR_CODE('ercb'),        /* use with SpeechErrorProcPtr*/
  102.     soPhonemeCallBack            = FOUR_CHAR_CODE('phcb'),        /* use with SpeechPhonemeProcPtr*/
  103.     soWordCallBack                = FOUR_CHAR_CODE('wdcb'),
  104.     soSynthExtension            = FOUR_CHAR_CODE('xtnd'),
  105.     soSoundOutput                = FOUR_CHAR_CODE('sndo')
  106. };
  107.  
  108.  
  109. /*------------------------------------------*/
  110. /* Speaking Mode Constants                     */
  111. /*------------------------------------------*/
  112.  
  113. enum {
  114.     modeText                    = FOUR_CHAR_CODE('TEXT'),        /* input mode constants                     */
  115.     modePhonemes                = FOUR_CHAR_CODE('PHON'),
  116.     modeNormal                    = FOUR_CHAR_CODE('NORM'),        /* character mode and number mode constants */
  117.     modeLiteral                    = FOUR_CHAR_CODE('LTRL')
  118. };
  119.  
  120.  
  121.  
  122. enum {
  123.     soVoiceDescription            = FOUR_CHAR_CODE('info'),
  124.     soVoiceFile                    = FOUR_CHAR_CODE('fref')
  125. };
  126.  
  127.  
  128. typedef struct OpaqueSpeechChannel*     SpeechChannel;
  129.  
  130.  
  131. struct VoiceSpec {
  132.     OSType                             creator;
  133.     OSType                             id;
  134. };
  135. typedef struct VoiceSpec                VoiceSpec;
  136. typedef VoiceSpec *                        VoiceSpecPtr;
  137.  
  138.  
  139. enum {
  140.     kNeuter                        = 0,
  141.     kMale                        = 1,
  142.     kFemale                        = 2
  143. };
  144.  
  145.  
  146.  
  147.  
  148.  
  149. struct VoiceDescription {
  150.     long                             length;
  151.     VoiceSpec                         voice;
  152.     long                             version;
  153.     Str63                             name;
  154.     Str255                             comment;
  155.     short                             gender;
  156.     short                             age;
  157.     short                             script;
  158.     short                             language;
  159.     short                             region;
  160.     long                             reserved[4];
  161. };
  162. typedef struct VoiceDescription            VoiceDescription;
  163.  
  164.  
  165.  
  166. struct VoiceFileInfo {
  167.     FSSpec                             fileSpec;
  168.     short                             resID;
  169. };
  170. typedef struct VoiceFileInfo            VoiceFileInfo;
  171.  
  172. struct SpeechStatusInfo {
  173.     Boolean                         outputBusy;
  174.     Boolean                         outputPaused;
  175.     long                             inputBytesLeft;
  176.     short                             phonemeCode;
  177. };
  178. typedef struct SpeechStatusInfo            SpeechStatusInfo;
  179.  
  180.  
  181.  
  182. struct SpeechErrorInfo {
  183.     short                             count;
  184.     OSErr                             oldest;
  185.     long                             oldPos;
  186.     OSErr                             newest;
  187.     long                             newPos;
  188. };
  189. typedef struct SpeechErrorInfo            SpeechErrorInfo;
  190.  
  191.  
  192.  
  193. struct SpeechVersionInfo {
  194.     OSType                             synthType;
  195.     OSType                             synthSubType;
  196.     OSType                             synthManufacturer;
  197.     long                             synthFlags;
  198.     NumVersion                         synthVersion;
  199. };
  200. typedef struct SpeechVersionInfo        SpeechVersionInfo;
  201.  
  202.  
  203.  
  204. struct PhonemeInfo {
  205.     short                             opcode;
  206.     Str15                             phStr;
  207.     Str31                             exampleStr;
  208.     short                             hiliteStart;
  209.     short                             hiliteEnd;
  210. };
  211. typedef struct PhonemeInfo                PhonemeInfo;
  212.  
  213.  
  214. struct PhonemeDescriptor {
  215.     short                             phonemeCount;
  216.     PhonemeInfo                     thePhonemes[1];
  217. };
  218. typedef struct PhonemeDescriptor        PhonemeDescriptor;
  219.  
  220. struct SpeechXtndData {
  221.     OSType                             synthCreator;
  222.     Byte                             synthData[2];
  223. };
  224. typedef struct SpeechXtndData            SpeechXtndData;
  225.  
  226.  
  227. struct DelimiterInfo {
  228.     Byte                             startDelimiter[2];
  229.     Byte                             endDelimiter[2];
  230. };
  231. typedef struct DelimiterInfo            DelimiterInfo;
  232.  
  233. typedef CALLBACK_API( void , SpeechTextDoneProcPtr )(SpeechChannel chan, long refCon, const void **nextBuf, unsigned long *byteLen, long *controlFlags);
  234. typedef CALLBACK_API( void , SpeechDoneProcPtr )(SpeechChannel chan, long refCon);
  235. typedef CALLBACK_API( void , SpeechSyncProcPtr )(SpeechChannel chan, long refCon, OSType syncMessage);
  236. typedef CALLBACK_API( void , SpeechErrorProcPtr )(SpeechChannel chan, long refCon, OSErr theError, long bytePos);
  237. typedef CALLBACK_API( void , SpeechPhonemeProcPtr )(SpeechChannel chan, long refCon, short phonemeOpcode);
  238. typedef CALLBACK_API( void , SpeechWordProcPtr )(SpeechChannel chan, long refCon, unsigned long wordPos, unsigned short wordLen);
  239. typedef STACK_UPP_TYPE(SpeechTextDoneProcPtr)                     SpeechTextDoneUPP;
  240. typedef STACK_UPP_TYPE(SpeechDoneProcPtr)                         SpeechDoneUPP;
  241. typedef STACK_UPP_TYPE(SpeechSyncProcPtr)                         SpeechSyncUPP;
  242. typedef STACK_UPP_TYPE(SpeechErrorProcPtr)                         SpeechErrorUPP;
  243. typedef STACK_UPP_TYPE(SpeechPhonemeProcPtr)                     SpeechPhonemeUPP;
  244. typedef STACK_UPP_TYPE(SpeechWordProcPtr)                         SpeechWordUPP;
  245. enum { uppSpeechTextDoneProcInfo = 0x0000FFC0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  246. enum { uppSpeechDoneProcInfo = 0x000003C0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes) */
  247. enum { uppSpeechSyncProcInfo = 0x00000FC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes) */
  248. enum { uppSpeechErrorProcInfo = 0x00003BC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 2_bytes, 4_bytes) */
  249. enum { uppSpeechPhonemeProcInfo = 0x00000BC0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes, 2_bytes) */
  250. enum { uppSpeechWordProcInfo = 0x00002FC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 2_bytes) */
  251. #define NewSpeechTextDoneProc(userRoutine)                         (SpeechTextDoneUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechTextDoneProcInfo, GetCurrentArchitecture())
  252. #define NewSpeechDoneProc(userRoutine)                             (SpeechDoneUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechDoneProcInfo, GetCurrentArchitecture())
  253. #define NewSpeechSyncProc(userRoutine)                             (SpeechSyncUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechSyncProcInfo, GetCurrentArchitecture())
  254. #define NewSpeechErrorProc(userRoutine)                         (SpeechErrorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechErrorProcInfo, GetCurrentArchitecture())
  255. #define NewSpeechPhonemeProc(userRoutine)                         (SpeechPhonemeUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechPhonemeProcInfo, GetCurrentArchitecture())
  256. #define NewSpeechWordProc(userRoutine)                             (SpeechWordUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechWordProcInfo, GetCurrentArchitecture())
  257. #define CallSpeechTextDoneProc(userRoutine, chan, refCon, nextBuf, byteLen, controlFlags)  CALL_FIVE_PARAMETER_UPP((userRoutine), uppSpeechTextDoneProcInfo, (chan), (refCon), (nextBuf), (byteLen), (controlFlags))
  258. #define CallSpeechDoneProc(userRoutine, chan, refCon)             CALL_TWO_PARAMETER_UPP((userRoutine), uppSpeechDoneProcInfo, (chan), (refCon))
  259. #define CallSpeechSyncProc(userRoutine, chan, refCon, syncMessage)  CALL_THREE_PARAMETER_UPP((userRoutine), uppSpeechSyncProcInfo, (chan), (refCon), (syncMessage))
  260. #define CallSpeechErrorProc(userRoutine, chan, refCon, theError, bytePos)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppSpeechErrorProcInfo, (chan), (refCon), (theError), (bytePos))
  261. #define CallSpeechPhonemeProc(userRoutine, chan, refCon, phonemeOpcode)  CALL_THREE_PARAMETER_UPP((userRoutine), uppSpeechPhonemeProcInfo, (chan), (refCon), (phonemeOpcode))
  262. #define CallSpeechWordProc(userRoutine, chan, refCon, wordPos, wordLen)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppSpeechWordProcInfo, (chan), (refCon), (wordPos), (wordLen))
  263. EXTERN_API( NumVersion )
  264. SpeechManagerVersion            (void)                                                        FOURWORDINLINE(0x203C, 0x0000, 0x000C, 0xA800);
  265.  
  266. EXTERN_API( OSErr )
  267. MakeVoiceSpec                    (OSType                 creator,
  268.                                  OSType                 id,
  269.                                  VoiceSpec *            voice)                                FOURWORDINLINE(0x203C, 0x0604, 0x000C, 0xA800);
  270.  
  271. EXTERN_API( OSErr )
  272. CountVoices                        (short *                numVoices)                            FOURWORDINLINE(0x203C, 0x0108, 0x000C, 0xA800);
  273.  
  274. EXTERN_API( OSErr )
  275. GetIndVoice                        (short                     index,
  276.                                  VoiceSpec *            voice)                                FOURWORDINLINE(0x203C, 0x030C, 0x000C, 0xA800);
  277.  
  278. EXTERN_API( OSErr )
  279. GetVoiceDescription                (const VoiceSpec *        voice,
  280.                                  VoiceDescription *        info,
  281.                                  long                     infoLength)                            FOURWORDINLINE(0x203C, 0x0610, 0x000C, 0xA800);
  282.  
  283. EXTERN_API( OSErr )
  284. GetVoiceInfo                    (const VoiceSpec *        voice,
  285.                                  OSType                 selector,
  286.                                  void *                    voiceInfo)                            FOURWORDINLINE(0x203C, 0x0614, 0x000C, 0xA800);
  287.  
  288. EXTERN_API( OSErr )
  289. NewSpeechChannel                (VoiceSpecPtr             voice,
  290.                                  SpeechChannel *        chan)                                FOURWORDINLINE(0x203C, 0x0418, 0x000C, 0xA800);
  291.  
  292. EXTERN_API( OSErr )
  293. DisposeSpeechChannel            (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x021C, 0x000C, 0xA800);
  294.  
  295. EXTERN_API( OSErr )
  296. SpeakString                        (ConstStr255Param         textToBeSpoken)                        FOURWORDINLINE(0x203C, 0x0220, 0x000C, 0xA800);
  297.  
  298. EXTERN_API( OSErr )
  299. SpeakText                        (SpeechChannel             chan,
  300.                                  const void *            textBuf,
  301.                                  unsigned long             textBytes)                            FOURWORDINLINE(0x203C, 0x0624, 0x000C, 0xA800);
  302.  
  303. EXTERN_API( OSErr )
  304. SpeakBuffer                        (SpeechChannel             chan,
  305.                                  const void *            textBuf,
  306.                                  unsigned long             textBytes,
  307.                                  long                     controlFlags)                        FOURWORDINLINE(0x203C, 0x0828, 0x000C, 0xA800);
  308.  
  309. EXTERN_API( OSErr )
  310. StopSpeech                        (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x022C, 0x000C, 0xA800);
  311.  
  312. EXTERN_API( OSErr )
  313. StopSpeechAt                    (SpeechChannel             chan,
  314.                                  long                     whereToStop)                        FOURWORDINLINE(0x203C, 0x0430, 0x000C, 0xA800);
  315.  
  316. EXTERN_API( OSErr )
  317. PauseSpeechAt                    (SpeechChannel             chan,
  318.                                  long                     whereToPause)                        FOURWORDINLINE(0x203C, 0x0434, 0x000C, 0xA800);
  319.  
  320. EXTERN_API( OSErr )
  321. ContinueSpeech                    (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x0238, 0x000C, 0xA800);
  322.  
  323. EXTERN_API( short )
  324. SpeechBusy                        (void)                                                        FOURWORDINLINE(0x203C, 0x003C, 0x000C, 0xA800);
  325.  
  326. EXTERN_API( short )
  327. SpeechBusySystemWide            (void)                                                        FOURWORDINLINE(0x203C, 0x0040, 0x000C, 0xA800);
  328.  
  329. EXTERN_API( OSErr )
  330. SetSpeechRate                    (SpeechChannel             chan,
  331.                                  Fixed                     rate)                                FOURWORDINLINE(0x203C, 0x0444, 0x000C, 0xA800);
  332.  
  333. EXTERN_API( OSErr )
  334. GetSpeechRate                    (SpeechChannel             chan,
  335.                                  Fixed *                rate)                                FOURWORDINLINE(0x203C, 0x0448, 0x000C, 0xA800);
  336.  
  337. EXTERN_API( OSErr )
  338. SetSpeechPitch                    (SpeechChannel             chan,
  339.                                  Fixed                     pitch)                                FOURWORDINLINE(0x203C, 0x044C, 0x000C, 0xA800);
  340.  
  341. EXTERN_API( OSErr )
  342. GetSpeechPitch                    (SpeechChannel             chan,
  343.                                  Fixed *                pitch)                                FOURWORDINLINE(0x203C, 0x0450, 0x000C, 0xA800);
  344.  
  345. EXTERN_API( OSErr )
  346. SetSpeechInfo                    (SpeechChannel             chan,
  347.                                  OSType                 selector,
  348.                                  const void *            speechInfo)                            FOURWORDINLINE(0x203C, 0x0654, 0x000C, 0xA800);
  349.  
  350. EXTERN_API( OSErr )
  351. GetSpeechInfo                    (SpeechChannel             chan,
  352.                                  OSType                 selector,
  353.                                  void *                    speechInfo)                            FOURWORDINLINE(0x203C, 0x0658, 0x000C, 0xA800);
  354.  
  355. EXTERN_API( OSErr )
  356. TextToPhonemes                    (SpeechChannel             chan,
  357.                                  const void *            textBuf,
  358.                                  unsigned long             textBytes,
  359.                                  Handle                 phonemeBuf,
  360.                                  long *                    phonemeBytes)                        FOURWORDINLINE(0x203C, 0x0A5C, 0x000C, 0xA800);
  361.  
  362. EXTERN_API( OSErr )
  363. UseDictionary                    (SpeechChannel             chan,
  364.                                  Handle                 dictionary)                            FOURWORDINLINE(0x203C, 0x0460, 0x000C, 0xA800);
  365.  
  366.  
  367.  
  368.  
  369. #if PRAGMA_STRUCT_ALIGN
  370.     #pragma options align=reset
  371. #elif PRAGMA_STRUCT_PACKPUSH
  372.     #pragma pack(pop)
  373. #elif PRAGMA_STRUCT_PACK
  374.     #pragma pack()
  375. #endif
  376.  
  377. #ifdef PRAGMA_IMPORT_OFF
  378. #pragma import off
  379. #elif PRAGMA_IMPORT
  380. #pragma import reset
  381. #endif
  382.  
  383. #ifdef __cplusplus
  384. }
  385. #endif
  386.  
  387. #endif /* __SPEECHSYNTHESIS__ */
  388.  
  389.